from core.support import set_cutscene
from core.item import Item
from core.action import Action
from items.fiftyshades import Fiftyshades
from items.bacardi151 import Bacardi151
from items.molotov import Molotov
from items.flamingfifty import Flamingfifty
from core.game import Game
from core.support import get_game

class Lighter(Item):
    def __init__(self):
        Item.__init__(self, "lighter")    # do basic initialization for every item
        
        # build list of actions
        self.add_action(uselighter)
    
    def get_description(self):
        return "Lighter"

# define actions for this item

class uselighter(Action):
    def __init__(self):
        Action.__init__(self, "uselighter")    # do basic initialization for every action
    
    # return description of action (used in label on webpage)
    def get_description(self):
        return "Use Lighter"
    
    # return http method to use when user clicks on this action
    # use "get" if just moving to another room.  if changing something
    # like the state of an inventory item or room then use "post"
    def get_method(self):
        return "post"
    
    # only works in basement. add cutscene
    def do_action(self,game,room,request):
        game = get_game()
        player = game.get_player()
        
        if room.get_id() == 'sea7caughtfish': #Insert actual shark room here
            set_cutscene("I've got my lighter, now I guess I should cook my fish")
        elif room.get_id() == 'sea8hearhello':
                if '50shades' in player.inventory:
                    player.add_item(Flamingfifty())
                    player.pop_item('50shades')
                    set_cutscene("You've set your book on fire.  Use your new item to signal.")
                elif 'bacardi151' in player.inventory:
                    player.add_item(Molotov())
                    player.pop_item('bacardi151')
                    set_cutscene("You just made a Molotov Cocktail... this could be an awful idea.")
                else:
                    set_cutscene("I wish I had something to signal with.")
        else:
            set_cutscene("There's nothing to light here.")
        return